;(function($, $$)
{
    var WIDGET_CALL_FUNCTION = $$.WIDGET_CALL_FUNCTION = {
        baseUrl : "./javascript/jquery.base.{key}.js"
    };
    var WIDGET_LIST = "accordion buttonSet datePicker dialog dropDownList grid list menu progressBar slide tabs tip tree".split(" ");
    for(var i = 0, len = WIDGET_LIST.length; i < len; i++)
    {
        var widget = WIDGET_LIST[i];
        if(!$.isFunction($.fn[widget]))
        {
            ;(function()
            {
                var argumentsList = [],key = widget, widgetJson = {
                    argumentsList : argumentsList,
                    loading : false
                };
                WIDGET_CALL_FUNCTION[key] = widgetJson;
                $.fn[key] = function()
                {
                    if(!widgetJson.loading)
                    {
                        $.ajax({
                            url : WIDGET_CALL_FUNCTION.baseUrl.replace("{key}", key),
                            dataType : "script",
                            success : function(data)
                            {
                                for(var i = 0, len = argumentsList.length; i < len; i++)
                                {
                                    var args = argumentsList[i];
                                    $.fn[key].apply(args.pop(),args);
                                }
                                delete WIDGET_CALL_FUNCTION[key];
                            },
                            error : function(err, textStatus, errorThrown)
                            {
                            }
                        });
                        widgetJson.loading = true;
                    }
                    var args = Array.prototype.slice.call(arguments);
                    args.push(this);
                    argumentsList.push(args);
                };
            })();
        }
    }
})(jQuery, BASE);